package com.liu.project.controller;

import com.liu.project.pojo.Major;
import com.liu.project.pojo.Subject;
import com.liu.project.service.MajorService;
import com.liu.project.service.SubjectService;
import com.liu.project.utils.Message;
import io.swagger.annotations.Api;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

/**
 * @program: project
 * @description:
 * @author: 86187
 * @create: 2022-03-20 15:52
 **/
@Api(tags = "获取专业列表")
@Controller
@RequestMapping("/api/major")
public class MajorController {

    @Autowired
    MajorService majorService;

    @GetMapping("/all")
    @ApiResponse(code = 200,message = "请求成功",response = Message.class)
    @ResponseBody
    public Message<List<Major>> getAllMajor(){
        List<Major> all = majorService.getAll();
        return new Message<List<Major>>(200,"请求成功",all);
    }

    @PostMapping("/find/{key}")
    @ApiImplicitParam(name = "key",value = "专业名称关键字")
    @ApiResponse(code = 200,message = "请求成功",response = Message.class)
    @ResponseBody
    public Message<List<Major>> getMajorByKey(@PathVariable("key") String key){
        List<Major> majorByKey = majorService.getMajorByKey(key);
        return new Message<List<Major>>(200,"请求成功",majorByKey);
    }
}
